Conditions | 4 |
Total Lines | 25 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Inject } from '@nestjs/common'; |
||
12 | |||
13 | public async index(items: FairCalendarView[]): Promise<ICalendarOverview> { |
||
14 | const cooperative = await this.cooperativeRepository.find(); |
||
15 | if (!cooperative) { |
||
16 | throw new CooperativeNotFoundException(); |
||
17 | } |
||
18 | |||
19 | const overviewInDays: ICalendarOverview = { |
||
20 | mission: 0, |
||
21 | dojo: 0, |
||
22 | formationConference: 0, |
||
23 | leave: 0, |
||
24 | support: 0, |
||
25 | other: 0 |
||
26 | }; |
||
27 | |||
28 | for (const { time, type: itemType } of items) { |
||
29 | const type = itemType.startsWith('leave_') ? 'leave' : itemType; |
||
30 | const days = time / cooperative.getDayDuration(); |
||
31 | |||
32 | overviewInDays[type] = |
||
33 | Math.round((overviewInDays[type] + days) * 100) / 100; |
||
34 | } |
||
35 | |||
36 | return overviewInDays; |
||
37 | } |
||
39 |